<template>
	<page-container boxBackground="transparent" :isback="true" :shownav="true" :istabbox="false" :navtitle="navtitle">
		<view class="home-root">
			<view class="content-item">
				<view class="content-item-title">
					<u-parse :content="detailData.newsTitle"></u-parse>
				</view>
				<view class="content-item-time">
					{{ detailData.createTime.substr(0,10) }}
				</view>
				<view class="content-item-img" v-if="detailData.newsCover && detailData.newsCover !== ''">
					<image :src="detailData.newsCover && detailData.newsCover !== '' ? detailData.newsCover : ''" />
				</view>
				<u-parse :content="detailData.newsContent"></u-parse>
			</view>
		</view>
		<u-loading-page :loading="loading"></u-loading-page>
	</page-container>
</template>

<script>
	import {
		getQueryHeaders,
		requestGet
	} from "@/util/means/request";
	import {
		QueryGetTalkNewsDetail,
		QueryGetBusExchangeNewsDetail
	} from "@/api/message";
	import {
		getFileAccessHttpUrl
	} from "@/util/fileUtil";

	export default {
		data() {
			return {
				loading: false, // 加载中
				talkNewsId: "", //详情id
				detailData: {}, //详情数据
				navtitle: ''
			}
		},
		methods: {
			//获工作详情
			getBusExchangeNewsDetail(talkNewsId) {
				this.loading = true
				let ower = this
				requestGet({
					url: QueryGetBusExchangeNewsDetail,
					data: {
						id: talkNewsId
					},
					header: getQueryHeaders()
				}).then(res => {
					//格式化图片地址
					res.newsCover = getFileAccessHttpUrl(res.newsCover)
					ower.detailData = res
					ower.navtitle = res.newsTitle
				}).finally(res => {
					ower.loading = false
				})
			},
			//获取交流圈列表
			getTalkNewsDetail(talkNewsId) {
				this.loading = true
				let ower = this
				requestGet({
					url: QueryGetTalkNewsDetail,
					data: {
						talkNewsId
					},
					header: getQueryHeaders()
				}).then(res => {
					//格式化图片地址
					res.newsCover = getFileAccessHttpUrl(res.newsCover)
					ower.detailData = res
					ower.navtitle = res.newsTitle
				}).finally(res => {
					ower.loading = false
				})
			},
		},
		onLoad(params) {
			// 我的工作详情
			if (params.type == "work") {
				this.talkNewsId = params.talkNewsId
				let talkNewsId = this.talkNewsId
				this.getBusExchangeNewsDetail(talkNewsId)
			} else {
				this.talkNewsId = params.talkNewsId
				let talkNewsId = this.talkNewsId
				this.getTalkNewsDetail(talkNewsId)
			}
		},
		created() {

		},
		mounted() {}
	}
</script>

<style scoped lang="scss">
	.home-root {
		width: 100%;
		height: 100%;
		box-sizing: border-box;
		padding: 30rpx;
		overflow: auto;

		.content-item {
			padding: 30rpx;
			background-color: $bg-color-white;
			border-radius: $border-radius-lg;
			margin-bottom: 20rpx;

			.content-item-title {
				font-size: 32rpx;
			}

			.content-item-time {
				font-size: 26rpx;
				color: #ABABAB;
				margin: 20rpx 0 32rpx 0;
			}

			.content-item-img {
				width: 100%;

				image {
					width: 100%;
					height: 400rpx;
				}

			}
		}
	}
</style>